{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "import pickle\n",
    "import gzip\n",
    "\n",
    "\n",
    "mnistpklPath = '/Users/kongkong/PycharmProjects/aiinner/ai/code-of-enterprise-ai-technology-book/chapter14_MNIST/mnist.pkl.gz'\n",
    "# f = gzip.open('mnist.pkl.gz', 'rb')\n",
    "f = gzip.open(mnistpklPath, 'rb')\n",
    "training_data, validation_data, test_data = pickle.load(f, encoding=\"latin1\")\n",
    "f.close()\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n"
     ]
    }
   ],
   "source": [
    "print(len(training_data))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "39200000\n"
     ]
    }
   ],
   "source": [
    "print(training_data[0].size)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "outputs": [
    {
     "data": {
      "text/plain": "<Figure size 432x288 with 1 Axes>",
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWoAAAEICAYAAAB25L6yAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAONElEQVR4nO3de6ykdX3H8ffHXUSLNoocDbfjwWiw1lYwW29otWgtitH0j1pIsNqYbtJoio2JLvUPL39YTFprTWrj1muKghe0pdCq1EtarcWCIllYtnJZywq6UkTBekO//WOeA+N6ljMczpz5Muf9Sk7OzDPPznx/u8ubZ595ZjdVhSSpr/vNegBJ0t0z1JLUnKGWpOYMtSQ1Z6glqTlDLUnNGWrNRJK9SZ6zwvZnJNkzi5mkrgy1Wqmqf6+q41fbL8kbkpyzETNJs2aop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voJ8DHgacz3mpcdbI3r1rUuod4UH1NPEuDdwO6qeuvYQxcALx1uv5TRueu5UFVnVdUxVbXE6Nf1M1V1BvO95m8CNyQ5ftj0bOAq5njNjE55PCXJLw2/z5/N6A3UeV7zsoOt8QLgtCSHJjkOeAzwpTW9wqxPzI+daH8+8N/AtcDrZj3PlNb4dEZ/9LkCuHz4ej7wMEZvtn1t+H74rGed0vqfxV1vJs71moETgEuHX+t/AB66Cdb8RuBqYBfw98Ch87Zm4FxG5+B/wuiI+eV3t0bgdUPT9gDPW+vr+hFySWquy6kPSdJBGGpJas5QS1JzhlqSmjPUktScoZak5gy1JDX3/+BGz7HEXTFjAAAAAElFTkSuQmCC\n"
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "from matplotlib import pyplot as plt\n",
    "import numpy as np\n",
    "\n",
    "a = np.array([22,87,5,43,56,73,55,54,11,20,51,5,79,31,27])\n",
    "plt.hist(a, bins =  [0,20,40,60,80,100])\n",
    "plt.title(\"histogram\")\n",
    "plt.show()"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}